
const numbers = [1, 2, 3, 4, 5];
// forEach处理循环之外，还可以修改数据本身
numbers.forEach(function (number, index, arr) {
  arr[index] = number + 10
});

// console.log(numbers);


// forEach不能模仿map进行内部的return,它返回的结果是undefined
let asd = numbers.forEach(function (number, index, arr) {
  return number++
});

// console.log(asd);

// 删除数组中指定对象的方法
let arr = [
  {
    name: 'tom1',
    age: 10
  },
  {
    name: 'tom2',
    age: 10
  },
  {
    name: 'tom3',
    age: 10
  },
  {
    name: 'tom4',
    age: 10
  },
  {
    name: 'tom5',
    age: 10
  }
]

let brr = ['tom', 'tom4']

arr.forEach((item, index, arr) => {
  if (brr.includes(item.name)) {
    arr.splice(index, 1)
  }
})

console.log(arr);
